package com.springsource.a05CommonBeanFactoryPostProcessor;

import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.context.annotation.ConfigurationClassPostProcessor;
import org.springframework.context.support.GenericApplicationContext;

public class CommonBeanFactoryPostProcessor {

    public static void main(String[] args) {
        GenericApplicationContext context = new GenericApplicationContext();
        context.registerBean("config", Config.class);

        // 解析@Configuration、ComponentScan、@Bean注解
//        context.registerBean(ConfigurationClassPostProcessor.class);
        // 解析@Mapper注解
//        context.registerBean(MapperScannerConfigurer.class, beanDefinition ->
//        {
//            beanDefinition.getPropertyValues().add("basePackage", "com.springsource.a05CommonBeanFactoryPostProcessor.mapper");
//        });

        // 自己实现的解析@Component注解的过程
//        context.registerBean(MyConfigurationClassPostProcessor.class);

        // 自己实现的解析@Bean注解的过程
        context.registerBean(MyConfigurationClassPostProcessor2.class);

        // 自己实现的解析@Mapper注解的过程
        context.registerBean(MyMapperScannerConfigurer.class);

        context.refresh();

        for (String name : context.getBeanDefinitionNames()) {
            System.out.println(name);
        }

        context.close();
    }

}
